import React from "react";

class VoteMain extends React.Component {
  render() {
    const { supNum, oppNum } = this.props;
    let ratio = "--";
    let total = supNum + oppNum;
    if (total > 0) ratio = ((supNum / total) * 100).toFixed(2) + "%";
    return (
      <div className="main">
        <p>支持人数：{supNum}人</p>
        <p>反对人数：{oppNum}人</p>
        <p>支持率：{ratio}</p>
      </div>
    );
  }
}

export default VoteMain;
